﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Text;

public partial class topic_index : Basic
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public string Content
    {
        get
        {
            string str = Pub.LoadData(jsonUrl + "/topic/TopicList.ashx?count=8");
            List<Topic> lst = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Topic>>(str);
            System.Text.StringBuilder sb=new System.Text.StringBuilder();
            if (lst != null)
            {
                lst = lst.OrderByDescending(x => x.Id).ToList();
                for (int i = 0; i < lst.Count; i++)
                {
                    var c = lst[i];
                    if (c.IsEnable == true)
                    {
                        sb.AppendLine("<li>");
                        sb.AppendLine("   <div class=\"rdzt_picBorder\"><a href=\"topic_d.aspx?id=" + c.Id + "\" class=\"b\"><img style=\"border:0px\" src=\"images/topics/face/" + c.ImageUrl + "\" width=\"132px\" height=\"106px\" alt=\"标题图片\" /></a></div>");
                        sb.AppendLine("   <div class=\"rdzt_preview_c1\"><span class=\"h3 gray_t\"><a href=\"topic_d.aspx?id=" + c.Id + "\" class=\"b\">" + c.Title + "</a></span><br />");
                        sb.AppendLine("   <span class=\"gray\">" + c.Summary + "</span><a href=\"topic_" + c.Id + ".shtml\" class=\"b\">[详细]</a></div>");
                        sb.AppendLine("</li>");
                    }
                }
            }
            return sb.ToString(); ;
        }
    }

    class TopImage
    {
        public string FileName
        {
            get;
            set;
        }

        public string Url
        {
            get;
            set;
        }
    }

    public string ImgTop
    {
        get
        {
            string str = Pub.LoadData(jsonUrl + "topic/TopicTopImg.ashx");
            var c= Newtonsoft.Json.JsonConvert.DeserializeObject<TopImage>(str);
            StringBuilder sb=new StringBuilder();
            sb.AppendLine("<a href=\""+c.Url+"\">");
            sb.AppendLine("<img src='images/topics/face/"+c.FileName+"' width=\"960\" height=\"140\" style=\"border:0px\" /></a>");
            return sb.ToString();
        }
    }
}